package laboratoryQ.experiment.ui.reportage;

import java.util.List;

import javax.swing.JComponent;

import laboratoryQ.flatness.ui.DrawDiagramOnComponent;
import laboratoryQ.flatness.ui.IDiagramList2componentStrategy;

public abstract class BaseER2CConverter implements IExperimentResult2componentConverter {
	protected IDiagramList2componentStrategy diagramList2componentStrategy = new DrawDiagramOnComponent();
	private String experimentTitle;
	private String[] viewTitles;

	public BaseER2CConverter(String experimentTitle, String ... viewTitles) {
		this.experimentTitle = experimentTitle;
		this.viewTitles = viewTitles;
	}
	public void setDiagramList2componentStrategy(
			IDiagramList2componentStrategy diagramList2componentStrategy
	) {
		this.diagramList2componentStrategy = diagramList2componentStrategy;
	}

	@Override
	public String getExperimentTitle() {
		return experimentTitle;
	}

	@Override
	public String getViewTitleAt(int position) {
		if (viewTitles.length > position) {
			return viewTitles[position];
		} else {
			return "Undefined title: " + position;
		}
	}

	@Override
	public void onExperimentRunStart(List<JComponent> viewComponents) {
		for (JComponent component : viewComponents) {
			diagramList2componentStrategy.onExperimentRunStart(component);
		}
	}
}
